using System;
using System.Windows;
using System.Configuration;
using System.Globalization;
using System.Collections.Generic;

using SBPweb.Localization;
using SBPweb.Modules.Modularity;
using SBPweb.Security.Authorization;

namespace SBPweb.Presentation.Windows.WPF.Host
{
    /// <summary>
    /// Interaction logic for App.xaml
    /// </summary>

    public partial class App : System.Windows.Application
    {

        #region Private fields

        internal static CultureInfo[] SUPPORTED_CULTURES = new CultureInfo[] { new CultureInfo("hu-HU"), new CultureInfo("en-US") };

        private static ModuleLoader sModuleLoader;
        private static ResourceHandler sResourceHandler;
        private static MembershipUser sMembership;

        private MainWindow sMainWindow;

        #endregion

        #region Constructor logic

        public App()
        {
            Environment.CurrentDirectory = AppDomain.CurrentDomain.BaseDirectory;

            sMembership = new MembershipUser();
			LogManager logManager = new LogManager();

            sModuleLoader = new ModuleLoader(   SBPweb.Presentation.Windows.WPF.Host.Properties.Settings.Default.PathOfModules,
                                                SBPweb.Presentation.Windows.WPF.Host.Properties.Settings.Default.PathOfModulesConfigurationFile,
                                                SBPweb.Presentation.Windows.WPF.Host.Properties.Settings.Default.ApplicationTitle,
                                                "SBPweb tech",
												logManager);

            sResourceHandler = new ResourceHandler(typeof(MainWindow), new List<CultureInfo>(SUPPORTED_CULTURES));

            this.MainWindow = sMainWindow = new MainWindow();
            sModuleLoader.Initialize(sMainWindow, null);

            this.MainWindow.Show();
        }

        protected override void OnExit(ExitEventArgs e)
        {
//            sModuleLoader.Finalize();
            base.OnExit(e);
        }

        #endregion

        #region Property accessors

        /*
        public static bool IsInExplorerMode
        {
            get
            {
                return sIsInExplorerMode;
            }
        }
        */

        public static ModuleLoader Loader
        {
            get
            {
                return sModuleLoader;
            }
        }

        public static ResourceHandler Resources
        {
            get
            {
                return sResourceHandler;
            }
        }

        #endregion


    }
}